#include "stdafx.h"
#include "music.h"
MusicPlayer::MusicPlayer(HWND hWnd,char* file){
	this->hWnd=hWnd;
	BASS_Init(-1, 44100, 0, this->hWnd, NULL); 
	isPaused=TRUE;
	this->hStream=BASS_StreamCreateFile(FALSE, file, 0, 0, 0);
}

MusicPlayer::~MusicPlayer(){
	BASS_Free();

}


void MusicPlayer::Play(){
	BASS_ChannelPlay(this->hStream,FALSE);
	isPaused=FALSE;
}
void MusicPlayer::Replay(){
	BASS_ChannelPlay(this->hStream,TRUE);
	isPaused=FALSE;
}
void MusicPlayer::Pause(){
	BASS_ChannelPause(hStream);
	isPaused=TRUE;
}
void MusicPlayer::Stop(){
	BASS_ChannelStop(hStream);
	isPaused=TRUE;
}
void MusicPlayer::SetVolumn(int volumn){
	if(volumn>=100)
		volumn=100;
    if(volumn<=0)
		volumn=0;
	this->volumn=volumn;
	BASS_SetVolume((float)volumn/(float)100);
	isPaused=FALSE;
} 
